function RX = DSP_DecisionQAM_SP(RX, M)
% QAM symbol decision
% RX can be 1-D or 2-D array
% power normailization is carried along the 1st dimension if RX is 2-D

R = real(RX);
I = imag(RX);

B = sqrt(M)-1;

R = (round(R/2+0.5)-0.5)*2;
I = (round(I/2+0.5)-0.5)*2;

% boundary handling
R(R >  B) =  B;
R(R < -B) = -B;
I(I >  B) =  B;
I(I < -B) = -B;

RX = complex(R, I);

